<!-- 权限配置 -->
<div class="easyui-layout" data-options="fit:true,border:false">
    <div id="mainContent" data-options="region:'north',border:false" >
        <div class="searchIndex">
            <ul>
                <li>
                    <label>关键字:</label>
                    <input id="txtQueryAuthName" name="txtQueryAuthName" class="base-input" maxlength="25" style="width:150px;">
                </li>
                <li>
                    <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-searchWin8',plain:true" onclick="queryAuthoritiesByName()">查询</a>
                </li>
            </ul>
        </div>
    </div>
    <div data-options="region:'center',border:false" class="paginColor">
        <div id="configurationButton" style="padding-left:10px;">
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-add-win8',plain:true" onClick="showNewAuthority()">新增</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-trackRecordwin8',plain:true" onClick="showNewAuthority()">修改</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-searchWin8',plain:true" onClick="showAuthorityView()">查看</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-removeWin8',plain:true" onclick="deleteAuthorities()">删除</a>
        </div>
        <table id="tblQueryAuthList" class="easyui-datagrid" 
         data-options="toolbar:'#configurationButton',
         fit:true,autoRowHeight:false,rownumbers:true,border:false,
         fitColumns:true,singleSelect:false,pagination:true,
         url:'',
         pageNumber:1">   
            <thead>
                <tr>                                     
                    <th data-options="field:'code',width:100,align:'center'">权限代码</th>
                    <th data-options="field:'name',width:100,align:'center'">权限名称</th>   
                </tr>
            </thead>
        </table>
    </div>
</div>

<div id="addauthority" class="easyui-dialog" data-options="title:'新增权限',closable:true,closed:true,modal:true,width:800,height:480">
    <div id="gridBtn" class="con_form">
        <ul>
            <li>
                <label>权限代码:</label>
                <input id="addTxtAuthCode" name="addTxtAuthCode" class="easyui-validatebox base-input" data-options="required:true" style="width:150px;" onblur="existsAuthority();" maxlength="6">
            </li>
            <li>
                <label>权限名称:</label>
                <input id="addTxtAuthName" name="addTxtAuthName" class="easyui-validatebox base-input" data-options="required:true" style="width:250px;" maxlength="13">
            </li>
            <li>
                <a href="javascript:void(0);" class="easyui-linkbutton okButton" data-options="iconCls:'icon-okWin8'" onclick="saveAuthority()">确认</a>
            </li>
        </ul>
        <table id="addTblResourceList" class="easyui-datagrid" 
         data-options="rownumbers:true,border:false,fit:true,fitColumns:true,
         singleSelect:false,nowrap:false,pagination:false,
         url:'',queryParams:{name:''},height:280">   
            <thead>
                <tr>
                    <th data-options="field:'name',width:100,align:'center'">资源名称</th>
                    <th data-options="field:'source',width:100,align:'center'">资源值</th> 
                </tr>
            </thead>
        </table>
</div>

<script type="text/javascript">
    function showNewAuthority(){
        
        $("#addTxtAuthCode").val("");
        $("#addTxtAuthName").val("").validatebox('validate');
        // openDialog("#addauthority");
        $('#addauthority').dialog('open');
        //去掉按Enter键事件
        document.onkeydown = "";
        // setFocus($("#addTxtAuthCode"));
    }

    function selectResourceRows(data){
        var rows=$("#editTblResourceList").datagrid("getRows");
        if(rows){
           for(var i=rows.length-1;i>=0;i--){
               
               if(rows[i].selected==true){        
                  var rowIndex=$("#editTblResourceList").datagrid("getRowIndex",rows[i]);
                  $("#editTblResourceList").datagrid("selectRow",rowIndex);
               }
           }
        }
    }
    
    function showAuthorityView(){
        
        var rows=$("#tblQueryAuthList").datagrid("getSelections");
        if(!rows||(rows&&rows.length!=1)){
            //去掉按Enter键事件
            document.onkeydown = "";
            var msgAuth_1 = $.messager.alert("提示", "请先选择一行记录", "info");
            //捕捉messager关闭事件
            msgAuth_1.window({onClose:function(){
                dialogClose();
            }});
            return;
        }
        
        var authId = rows[0].id;
        queryAuthorityView(authId);
        // openDialog('#viewauthority');
        $('#viewauthority').dialog('open');
    }
</script>